<?
	global $file,$Drafts;
	$index = $Drafts->index_of($file);
?>

	var O_ID = '<?=$file->id?>';
	var USURPA = '<?=$file->usrp?>';

	Smernel.observe('file.js:loaded', function(){
		Object.extend(File, {
			loaded:function(){
				contents.setCode(this.contents);
				this.setreadonlycontent(!this.write);
			},
			setreadonlycontent:function(b){
				b = Boolean(b)
				contents.textarea.readOnly = b;
				contents.setReadOnly(b);
			},
			gathered:function(){
				this.args.set.contents = contents.getCode();
			}
		});
	});
	
	
	function showKeyboard(){
		var s = '<div style="margin-top:-10px; background:url(<?=Screen()->icon("keyboard.png", 128)?>) 0 -10px no-repeat; text-align:right">';
		s += '<h2>Shortcuts</h2><br /><small>&ldquo;cmd&rdquo; is apply key on mac &amp; ctrl on *nix/windoze</small>';
		s += '<div style="text-align:left; margin-top:90px">';
		s += '<small>operations:</small><br />';
		s += 'cmd + <strong>s</strong> : save current<br />';
		s += 'cmd + shift + <strong>n</strong> : new draft<br />';
		s += 'cmd + shift + <strong>u</strong> : usurp<br />';
		s += '<br /><small>history:</small><br />';
		s += 'cmd + <strong>z</strong> : undo<br />';
		s += 'cmd + shift + <strong>z</strong> : redo<br />';
		s += '<br /><small>insert:</small><br />';
		s += 'cmd + <strong>return</strong> : insert &lt;br /&gt;<br />';
		s += 'cmd + shift + <strong>d</strong> : insert &lt;div&gt;<br />';
		s += 'cmd + shift + <strong>s</strong> : insert &lt;span&gt;<br />';
		s += 'cmd + shift + <strong>e</strong> : insert &lt;em&gt;<br />';
		s += 'cmd + shift + <strong>g</strong> : insert &lt;strong&gt;<br />';
		s += '</div></div>';
		TUXalert(s);
	}

	window.queue(function(){
		Chrome.load({
			maincell:'contents_cp_iframe'
		});
		File.load(<?=json_encode($file->summary(2))?>);
		Drafts.load(<?=json_encode($index)?>);
		AutoSave();
	});

	